using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL
{

    /// <summary>
    /// The GuardianProfileTableManager class is responsible for managing BO.GuardianProfileTable objects in the system.
    /// </summary>
    [DataObjectAttribute()]
    public class GuardianProfileTableManager
    {

        #region "Public Methods"

        /// <summary>
        /// Gets a list with all GuardianProfileTable objects in the database.
        /// </summary>
        /// <returns>A list with all GuardianProfileTable from the database when the database contains any, or null otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static GuardianProfileTableList GetList()
        {
            return GuardianProfileTableDB.GetList();
        }

        /// <summary>
        /// Gets a single GuardianProfileTable from the database without its data.
        /// </summary>
        /// <param name="guardianProfileKey">The GuardianProfileKey of the GuardianProfileTable in the database.</param>
        /// <returns>A GuardianProfileTable object when the GuardianProfileKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static GuardianProfileTable GetItem(int guardianProfileKey)
        {
            return GetItem(guardianProfileKey, false);
        }

        /// <summary>
        /// Gets a single GuardianProfileTable from the database.
        /// </summary>
        /// <param name="guardianProfileKey">The GuardianProfileKey of the GuardianProfileTable in the database.</param>
        /// <param name="getGuardianProfileTableRecords">Determines whether to load all associated GuardianProfileTable records as well.</param>
        /// <returns>
        /// A GuardianProfileTable object when the GuardianProfileKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static GuardianProfileTable GetItem(int guardianProfileKey, bool getGuardianProfileTableRecords)
        {
            GuardianProfileTable myGuardianProfileTable = GuardianProfileTableDB.GetItem(guardianProfileKey);
            return myGuardianProfileTable;
        }

        /// <summary>
        /// Gets a single GuardianProfileTable from the database.
        /// </summary>
        /// <param name="UserAccountKey">The UserAccountKey of the GuardianProfileTable in the database.</param>
        /// <returns>
        /// A GuardianProfileTable object when the UserAccountKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static GuardianProfileTable GetItemByUserAccountKey(int UserAccountKey)
        {
            GuardianProfileTable myGuardianProfileTable = GuardianProfileTableDB.GetItemByUserAccountKey(UserAccountKey);
            return myGuardianProfileTable;
        }

        /// <summary>
        /// Saves a GuardianProfileTable in the database.
        /// </summary>
        /// <param name="myGuardianProfileTable">The GuardianProfileTable instance to save.</param>
        /// <returns>The new GuardianProfileKey if the GuardianProfileTable is new in the database or the existing GuardianProfileKey when an item was updated.</returns>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static int Save(GuardianProfileTable myGuardianProfileTable)
        {
            using (TransactionScope myTransactionScope = new TransactionScope())
            {
                int guardianProfileTableGuardianProfileKey = GuardianProfileTableDB.Save(myGuardianProfileTable);

                //  Assign the GuardianProfileTable its new (or existing GuardianProfileKey).
                myGuardianProfileTable.GuardianProfileKey = guardianProfileTableGuardianProfileKey;

                myTransactionScope.Complete();

                return guardianProfileTableGuardianProfileKey;
            }
        }

        /// <summary>
        /// Deletes a GuardianProfileTable from the database.
        /// </summary>
        /// <param name="myGuardianProfileTable">The GuardianProfileTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(GuardianProfileTable myGuardianProfileTable)
        {
            return GuardianProfileTableDB.Delete(myGuardianProfileTable.GuardianProfileKey);
        }

        #endregion

    }

}
